<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {
	public function index($hot_type=0){
	    $this->load->model('product_model');
	    switch($hot_type){
		case '0':
		    $this->load->model('news_m','item_model');
		    break;
		case '1':
		    $this->load->model('news_m','item_model');
		    break;
		case '2':
		    $this->load->model('tuvan','item_model');
		    break;
		case '3':
		    $this->load->model('news_m','item_model');
		    break;
	    }
	    $data['item1'] = $this->item_model->getall(5,0,0);
	    $data['item2'] = $this->product_model->getall(5,0,0);
		   //print_r($data);
	    $this->load->view('header');
	    $this->load->view('index',$data);
	    $this->load->view('footer');
	}
	
	function product($type=0,$offset=0,$limit=5){
	    $this->load->model('product_model');
	    $data['product']= $this->product_model->getall($limit,$offset,0,$type);
	    $this->load->view('header');
	    $this->load->view('top');
	    $this->load->view('norm',$data);
	    $this->load->view('footer');
	}
	function intro(){
	    $this->load->view('header');
	    $this->load->view('top');
	    $this->load->view('norm_intro');
	    $this->load->view('footer');
	}
	//health is news of event or knowledge
	function health($type='event',$limit=5,$offset=0){
	    $this->load->model('news_m');
	    $this->load->library('pagination');
	    if($type=='event'){
		$cat =2;
		$data['item']= $this->news_m->get_by_cat($limit,$offset,$cat);
		$this->db->where('category',2);
	    }
	    else{
		$cat =3;
		$data['item']= $this->news_m->get_by_cat($limit,$offset,$cat);
		$this->db->where('category',3);
	    }
	    $data['subtitle']='Y TẾ SỨC KHỎE';
	   // var_dump($data);
	    $config['uri_segment'] = 3;
            $config['total_rows'] = $this->db->count_all_results('news');
	    $config['per_page'] = $limit;
            $this->pagination->initialize($config);
            $data['paginator'] = $this->pagination->create_links();
	    $this->load->view('header');
	    $this->load->view('top');
	    $this->load->view('norm_news',$data);
	    $this->load->view('footer');
	}
	//company news include event or employing
	function company_news($type='event',$limit=10,$offset=0){
	     $this->load->model('news_m');
	    $this->load->library('pagination');
	    if($type=='event'){
		$cat =5;
		$data['item']= $this->news_m->get_by_cat($limit,$offset,$cat);
		$this->db->where('catagory',5);
	    }
	    else{
		$cat =6;
		$data['item']= $this->news_m->get_by_cat($limit,$offset,$cat);
		$this->db->where('catagory',6);
	    }
	    $data['subtitle']='TIN CÔNG TY';
	   // var_dump($data);
	    $config['uri_segment'] = 3;
            $config['total_rows'] = $this->db->count_all('news');
	    $config['per_page'] = $limit;
            $this->pagination->initialize($config);
            $data['paginator'] = $this->pagination->create_links();
	    $this->load->view('header');
	    $this->load->view('top');
	    $this->load->view('norm_news',$data);
	    $this->load->view('footer');
	}
	function distribution(){
	    $this->load->view('header');
	    $this->load->view('top');
	    $this->load->view('norm_phanphoi');
	    $this->load->view('footer');
	}
	function submit_distribution(){
	    $this->load->view('header');
	    $this->load->view('top');
	    $this->load->view('norm_dk_phanphoi');
	    $this->load->view('footer');
	}
	function advisory(){
	    $this->load->view('header');
	    $this->load->view('top');
	    $this->load->view('norm');
	    $this->load->view('footer');
	}
	function submit_advisory(){
	    $this->load->view('header');
	    $this->load->view('top');
	    $this->load->view('norm');
	    $this->load->view('footer');
	}
	function reference(){
	    $this->load->view('header');
	    $this->load->view('top');
	    $this->load->view('norm');
	    $this->load->view('footer');
	}
	function detail_news($news_id){
	    $this->load->model('news_m');
	    $this->load->library('pagination');
	   
	    $data['item']= $this->news_m->get_by_cat($limit,$offset,$cat);
	
	    //$data['subtitle']='Y TẾ SỨC KHỎE';
	   // var_dump($data);
	    
	    $this->load->view('header');
	    $this->load->view('top');
	    //$this->load->view('norm_news',$data);
	    $this->load->view('footer');
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */